package com.system.bill.controller;

import com.system.bill.bean.Bill;
import com.system.bill.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: BillController
 * @description: 预约单控制类
 * @author: Li Chuanwei
 * @date: 2023/11/26 20:46
 * @Company: Copyright [日期] by [作者或个人]
 **/

@RestController
@RequestMapping("/bill")
public class BillController {

    @Autowired
    private BillService billService;

    @PostMapping("/save")
    public boolean saveHandle(@RequestBody Bill bill){
        return billService.saveBill(bill);
    }

    @PostMapping("/saveGet")
    public Bill saveGetHandle(@RequestBody Bill bill){
        return billService.saveGetBill(bill);
    }

    @DeleteMapping("/del/{id}")
    public boolean deleteHandle(@PathVariable("id") int id){
        return billService.removeBillById(id);
    }

    @PutMapping("/update")
    public boolean updateHandle(@RequestBody Bill bill){
        return billService.modifyBill(bill);
    }

    @GetMapping("/get/{id}")
    public Bill getHandle(@PathVariable("id") int id){
        return billService.getBillById(id);
    }

    @GetMapping("/get/list")
    public List<Bill> listHandle(){
        return billService.listAllBills();
    }
}
